function wxPromisify(fn) {
    return function (obj = {}) {
      obj.url = "https://dubinbin.cn" + obj.url 
      if (obj.isLoading) {
        wx.showLoading({
          title: obj.loadingText || '请求中...',
        })
      }
  
      return new Promise((resolve, reject) => {
        obj.success = function (res) {
          resolve(res.data)
        }
  
        obj.fail = function (res) {
          console.log('接口请求错误', res)
          reject(res.data)
        }
  
        obj.complete = function (res) {
          console.log('接口请求完成', res)
          if (obj.isLoading) {
            wx.hideLoading()
          }
        }
  
        fn(obj)
      })
    }
  }


  function getGlobalParam() {
    // 全局参数
    var d = {
      sign: "",
      client: {caller: "wechat"},
      data: {},
      timestamp: new Date().getTime(),
      user: wx.getStorageSync('userInfo'),
    }
    return d
  }


  module.exports = {
    wxPromisify: wxPromisify,
    getGlobalParam: getGlobalParam,
  }